﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Ink;

namespace PaintApplication
{
    /// <summary>
    /// Logique d'interaction pour Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void InkCanvas_StrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)
        {

        }

        private void Rectangle_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // Set the color on the CurrentColor indicator and on the SurfaceInkCanvas
            IInputElement element = sender as IInputElement;
           // MessageBox.Show(e.Device.ToString());
            Color color = ((SolidColorBrush)((Rectangle)sender).Fill).Color;

            // Black means the user touched the transparent part of the wheel. In that 
            // case, leave the color set to its current value
            if (color != Colors.Black)
            {
                DrawingPadCanvas.DefaultDrawingAttributes.Color = color;
              //  CurrentColor.Fill = new SolidColorBrush(color);
            }

            // Set editing mode to ink
            DrawingPadCanvas.EditingMode = InkCanvasEditingMode.Ink;

            // Update the button image
            //EditModeButton.Content = DrawButtonImage;

        }

        private void DrawButton_Click(object sender, RoutedEventArgs e)
        {
            if (DrawingPadCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
                DrawingPadCanvas.EditingMode = InkCanvasEditingMode.Ink;

        }
       
        private void EraseButton_Click(object sender, RoutedEventArgs e)
        {
            if (DrawingPadCanvas.EditingMode ==InkCanvasEditingMode.Ink)
                DrawingPadCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;

        }

        private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            //MessageBox.Show(((Window)sender).Width+ " __ "+e.Source.ToString());
        }

        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            //MessageBox.Show(e.OriginalSource.ToString(), e.Source.ToString());
        }

        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
           // MessageBox.Show(e.OriginalSource.ToString(), e.Source.ToString());
        }
    }
}
